package com.ruoyi.common.utils;

public class PwdSecurityConfig {
	/**
     * 密码口令检测对应系统等级
     */
    public static String SYSTEM_GRADE  = ReadResource.systemGrade;

    /**
     * 是否检测密码口令长度标识
     */
    public static String CHECK_PASSWORD_LENGTH = ReadResource.checkPasswordLength;
    /**
     * 密码最小长度，默认为8
     */
    public static String MIN_LENGTH = ReadResource.limitPassMinLength;
    /**
     * 密码最大长度，默认为20
     */
    public static String MAX_LENGTH = ReadResource.limitPassMaxLength;

    /**
     * 是否包含数字
     */
    public static String CHECK_CONTAIN_DIGIT = ReadResource.checkContainDigit;
    /**
     * 是否区分大小写
     */
    public static String CHECK_DISTINGGUISH_CASE = ReadResource.checkContainUpperLowerCase;
    /**
     * 是否包含小写字母
     */
    public static String CHECK_LOWER_CASE = ReadResource.checkContainLowerCase;
    /**
     * 是否包含大写字母
     */
    public static String CHECK_UPPER_CASE = ReadResource.checkContainUpperCase;
    /**
     * 是否包含特殊符号
     */
    public static String CHECK_CONTAIN_SPECIAL_CHAR = ReadResource.checkContainSpecialChar;
    /**
     * 默认的特殊符号集合
     */
    public static String DEFAULT_SPECIAL_CHAR="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
    /**
     * 配置中的特殊符号集合
     */
    public static String SPECIAL_CHAR  = ReadResource.specialCharSet;

    /**
     * 是否检测键盘按键横向连续
     */
    public static String CHECK_HORIZONTAL_KEY_SEQUENTIAL  = ReadResource.checkHorizontalKeySequential;
    /**
     * 键盘物理位置横向不允许最小的连续个数
     */
    public static String LIMIT_HORIZONTAL_NUM_KEY = ReadResource.horizontalKeyLimitNum;
    /**
     * 是否检测键盘按键斜向连续
     */
    public static String CHECK_SLOPE_KEY_SEQUENTIAL = ReadResource.checkSlopeKeySequential;
    /**
     * 键盘物理位置斜向不允许最小的连续个数
     */
    public static String LIMIT_SLOPE_NUM_KEY = ReadResource.slopeKeyLimitNum;

    /**
     * 是否检测逻辑位置连续
     */
    public static String CHECK_LOGIC_SEQUENTIAL = ReadResource.checkLogicSequential;
    /**
     * 密码口令中字符在逻辑位置上不允许最小的连续个数
     */
    public static String LIMIT_LOGIC_NUM_CHAR = ReadResource.logicLimitNum;

    /**
     * 是否检测连续字符相同
     */
    public static String CHECK_SEQUENTIAL_CHAR_SAME = ReadResource.checkSequentialCharSame;
    /**
     * 密码口令中相同字符不允许最小的连续个数
     */
    public static String LIMIT_NUM_SAME_CHAR = ReadResource.sequentialCharNum;

    /**
     * 键盘横向方向规则
     */
    public static String[] KEYBOARD_HORIZONTAL_ARR = {
            "01234567890",
            "qwertyuiop",
            "asdfghjkl",
            "zxcvbnm",
    };
    /**
     * 键盘斜线方向规则
     */
    public static String[] KEYBOARD_SLOPE_ARR = {
            "1qaz",
            "2wsx",
            "3edc",
            "4rfv",
            "5tgb",
            "6yhn",
            "7ujm",
            "8ik,",
            "9ol.",
            "0p;/",
            "=[;.",
            "-pl,",
            "0okm",
            "9ijn",
            "8uhb",
            "7ygv",
            "6tfc",
            "5rdx",
            "4esz"
    };
    static {
        try{
            if("2".equals(SYSTEM_GRADE) || "3".equals(SYSTEM_GRADE) ) {

                if("".equals(CHECK_PASSWORD_LENGTH)){
                    CHECK_PASSWORD_LENGTH = "enable";
                    MIN_LENGTH = "8";
                    MAX_LENGTH = "20";
                }
                if("".equals(CHECK_CONTAIN_DIGIT)) {
                    CHECK_CONTAIN_DIGIT = "enable";
                }
                if("".equals(CHECK_DISTINGGUISH_CASE)) {
                    CHECK_DISTINGGUISH_CASE = "disable";
                }
                if("".equals(CHECK_LOWER_CASE)) {
                    CHECK_LOWER_CASE = "enable";
                }
                if("".equals(CHECK_UPPER_CASE)) {
                    CHECK_UPPER_CASE = "enable";
                }
                if("".equals(CHECK_CONTAIN_SPECIAL_CHAR)) {
                    if("2".equals(SYSTEM_GRADE)) {
                        CHECK_CONTAIN_SPECIAL_CHAR = "disable";
                    }else{
                        CHECK_CONTAIN_SPECIAL_CHAR = "enable";
                        if("".equals(SPECIAL_CHAR)) {
                            SPECIAL_CHAR = DEFAULT_SPECIAL_CHAR;
                        }
                    }
                }

                if("".equals(CHECK_HORIZONTAL_KEY_SEQUENTIAL)) {
                    CHECK_HORIZONTAL_KEY_SEQUENTIAL = "enable";
                    if("2".equals(SYSTEM_GRADE)) {
                        LIMIT_HORIZONTAL_NUM_KEY = "4";
                    }else{
                        LIMIT_HORIZONTAL_NUM_KEY = "3";
                    }
                }

                if("".equals(CHECK_SLOPE_KEY_SEQUENTIAL)) {
                    CHECK_SLOPE_KEY_SEQUENTIAL = "enable";
                    if("2".equals(SYSTEM_GRADE)) {
                        LIMIT_SLOPE_NUM_KEY = "4";
                    }else{
                        LIMIT_SLOPE_NUM_KEY = "3";
                    }
                }

                if("".equals(CHECK_LOGIC_SEQUENTIAL)) {
                    CHECK_LOGIC_SEQUENTIAL = "enable";
                    if("2".equals(SYSTEM_GRADE)) {
                        LIMIT_LOGIC_NUM_CHAR = "4";
                    }else{
                        LIMIT_LOGIC_NUM_CHAR = "3";
                    }

                }
                if("".equals(CHECK_SEQUENTIAL_CHAR_SAME)) {
                    CHECK_SEQUENTIAL_CHAR_SAME = "enable";
                    if("2".equals(SYSTEM_GRADE)) {
                        LIMIT_NUM_SAME_CHAR = "4";
                    }else{
                        LIMIT_NUM_SAME_CHAR = "3";
                    }
                }
            }else{
                SYSTEM_GRADE = "3";
                CHECK_PASSWORD_LENGTH = "enable";
                MIN_LENGTH = "8";
                MAX_LENGTH = "20";
                CHECK_CONTAIN_DIGIT = "enable";
                CHECK_LOWER_CASE = "enable";
                CHECK_UPPER_CASE = "enable";
                CHECK_CONTAIN_SPECIAL_CHAR = "enable";
                CHECK_HORIZONTAL_KEY_SEQUENTIAL = "enable";
                LIMIT_HORIZONTAL_NUM_KEY = "3";
                CHECK_SLOPE_KEY_SEQUENTIAL = "enable";
                LIMIT_SLOPE_NUM_KEY = "3";
                CHECK_LOGIC_SEQUENTIAL = "enable";
                LIMIT_LOGIC_NUM_CHAR = "3";
                CHECK_SEQUENTIAL_CHAR_SAME = "enable";
                LIMIT_NUM_SAME_CHAR = "3";
            }
        }catch(Exception e){
            System.out.println(e);
        }
    }

}
